package edu.chalmers.Framework_EXAMPLES;

import edu.chalmers.AV_2DPlatformerFramework.Model.GameObject;
import edu.chalmers.AV_2DPlatformerFramework.Model.UniversalInteractionLayer;
import edu.chalmers.AV_2DPlatformerFramework.Model.Hitbox;
import edu.chalmers.AV_2DPlatformerFramework.Model.Texture;
import edu.chalmers.AV_2DPlatformerFramework.Utility.Vector2D;
import edu.chalmers.AV_2DPlatformerFramework.*;
import edu.chalmers.AV_2DPlatformerFramework.Model.Hitbox.HitboxMalformedException;

/**
 *
 * @author Joakim
 */
public class BallExampleObject extends GameObject {
    public BallExampleObject(Vector2D velocity) throws Hitbox.HitboxMalformedException {
        super(null, new UniversalInteractionLayer(), 1, 1);
        Vector2D[] vertices = {new Vector2D(30, 0), new Vector2D(60, 0), 
            new Vector2D(90, 30), new Vector2D(90, 60), new Vector2D(60, 90), 
            new Vector2D(30, 90), new Vector2D(0, 60), new Vector2D(0, 30)};
        this.setHitbox(new Hitbox(vertices));
        String s = System.getProperty("file.separator");
        this.addTexture(
                new Texture("."+s+"src"+s+"main"+s+"java"+s+"Textures"
                            +s+"boll.gif", 
                this.getHitbox().getBounds2D()));
        setVelocity(velocity);
        }
    
    @Override
    public void onCollision(GameObject otherobject) {
        System.out.println("boll!");
    }

    @Override
    public GameObject copy() {
        try {
            return new BallExampleObject(getVelocity());
        } catch (HitboxMalformedException ex) {
            return null;
        }
    }
}
   
